home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_051
/
bison
/
diffs
/
bisondiffs
next >
Wrap
Internet Message Format
|
1992-05-06
|
11KB
From noao!seismo!ism780c!dougl Mon Dec 15 23:31:28 1986
Return-Path: <noao!seismo!ism780c!dougl>
Received: by mcdsun.uucp (3.2/SMI-3.2)
id AA00990; Mon, 15 Dec 86 23:31:22 MST
From: noao!seismo!ism780c!dougl
Received: by noao.ARPA (5.51/SAG.4)
id AA03654; Mon, 15 Dec 86 21:11:50 MST
Received: from ism780c.UUCP by seismo.CSS.GOV (5.54/1.14) with UUCP
id AA04556; Mon, 15 Dec 86 13:18:24 EST
Date: Mon, 15 Dec 86 13:18:24 EST
Message-Id: <8612151818.AA04556@seismo.CSS.GOV>
Sender: noao!seismo!ism780c!dougl
Subject: bison update (NOW it works on the AMIGA)
To: noao!mcdsun!fnf
Status: RO
To: seismo!noao!mcdsun!fnf
Fred,
Enclosed in the following shar script are the necessary changes to make
bison (fish #4) work correctly on the amiga. I did not bother making a
floppy etc for this because the changes, once I figured out what was
going on were pretty minimal. The problem seems to be that bison trys
to unallocate non allocated memory as well as allocated memory. The
unix malloc checks for this type of case and doesn't do anything. I
set up allocate/FREE to do a similar thing. Also the clearing of memory
in the allocate routine seems to be causing problems. I changed it to
simply call calloc instead. I added a string.h type file, although it
doesn't need any of the return codes from the string functions, I wanted
to remove that error message. Finally I changed calc, so that typing a
'Q' as a command will exit out of the calc program. (I got tired of
rebooting everytime I tested the calc program). You should be able
drop these changes over the bison on fish #4, and get a working bison.
I thought fixing bison up would be a lot easier than writing my own.
Thanks again for the idea of using the ANSI.C (mod.sources) parser,
I have a copy, that I've updated to current standards, and now with
bison I might be able to make some better progress.
I haven't sent these changes onto the GNU people as I currently
don't an address. If you have an address, could you pass on the changes,
and possibly the address back this way?
Have a Nice christmas,
Doug Leavitt
------------------- CUT HERE ------------------------------------------
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# string.h
# new.h
# allocate.c
# calc.y
# This archive created: Sun Dec 14 12:52:21 1986
cat << \SHAR_EOF > string.h
/*
* string function definition file, used in the amiga port of
* bison.
*/
/* Definitions for string routines, when the string file doesn't exist
IE for the amiga port of bison
copyright (C) 1986 Douglas J Leavitt (this file only)
Permission is granted to anyone to make or distribute verbatim copies of this program
provided that the copyright notice and this permission notice are preserved;
and provided that the recipient is not asked to waive or limit his right to
redistribute copies as permitted by this permission notice;
and provided that anyone possessing an executable copy
is granted access to copy the source code, in machine-readable form,
in some reasonable manner.
Permission is granted to distribute derived works or enhanced versions of
this program under the above conditions with the additional condition
that the entire derivative or enhanced work
must be covered by a permission notice identical to this one.
Anything distributed as part of a package containing portions derived
from this program, which cannot in current practice perform its function usefully
in the absense of what was derived directly from this program,
is to be considered as forming, together with the latter,
a single work derived from this program,
which must be entirely covered by a permission notice identical to this one
in order for distribution of the package to be permitted.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
extern char *strcat(), *strncat(), *strcpy(), *strncpy();
extern char *strchr(), *strrchr();
extern int strcmp(), strncmp(), strlen();
SHAR_EOF
cat << \SHAR_EOF > new.h
/* Storage allocation interface for bison,
copyright (C) 1984 Bob Corbett and Richard Stallman
Permission is granted to anyone to make or distribute verbatim copies of this program
provided that the copyright notice and this permission notice are preserved;
and provided that the recipient is not asked to waive or limit his right to
redistribute copies as permitted by this permission notice;
and provided that anyone possessing an executable copy
is granted access to copy the source code, in machine-readable form,
in some reasonable manner.
Permission is granted to distribute derived works or enhanced versions of
this program under the above conditions with the additional condition
that the entire derivative or enhanced work
must be covered by a permission notice identical to this one.
Anything distributed as part of a package containing portions derived
from this program, which cannot in current practice perform its function usefully
in the absense of what was derived directly from this program,
is to be considered as forming, together with the latter,
a single work derived from this program,
which must be entirely covered by a permission notice identical to this one
in order for distribution of the package to be permitted.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
#define NEW(t) ((t *) allocate((unsigned) sizeof(t)))
#define NEW2(n, t) ((t *) allocate((unsigned) ((n) * sizeof(t))))
#ifdef AMIGA
#define FREE(x) bisonfree(x);
#else
#define FREE(x) {if(x) free((char *) (x));}
#endif
extern char *allocate();
SHAR_EOF
cat << \SHAR_EOF > allocate.c
/* Allocate and clear storage for bison,
copyright (C) 1984 Bob Corbett and Richard Stallman
Permission is granted to anyone to make or distribute verbatim copies of this program
provided that the copyright notice and this permission notice are preserved;
and provided that the recipient is not asked to waive or limit his right to
redistribute copies as permitted by this permission notice;
and provided that anyone possessing an executable copy
is granted access to copy the source code, in machine-readable form,
in some reasonable manner.
Permission is granted to distribute derived works or enhanced versions of
this program under the above conditions with the additional condition
that the entire derivative or enhanced work
must be covered by a permission notice identical to this one.
Anything distributed as part of a package containing portions derived
from this program, which cannot in current practice perform its function usefully
in the absense of what was derived directly from this program,
is to be considered as forming, together with the latter,
a single work derived from this program,
which must be entirely covered by a permission notice identical to this one
in order for distribution of the package to be permitted.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
#include <stdio.h>
char *
allocate(n)
register unsigned n;
{
register char *block;
register char *cp;
register char *cend;
register int *ip;
#ifdef AMIGA
extern char *calloc();
#else
extern char *malloc();
#endif
#ifdef AMIGA
block = calloc(n+4,1);
#else
block = malloc(n);
#endif
if (block == NULL)
{
fprintf(stderr, "storage limit exceeded");
done(1);
}
#ifdef AMIGA
block[0] = 'A';
block[1] = 'M';
block[2] = 'E';
block[3] = 'M';
return(block+4);
#else
cp = block;
cend = block + n;
while (cp < cend)
*cp++ = 0;
if (n < 4)
{
while (cp < cend)
*cp++ = 0;
}
else
{
while (((unsigned) cp) & 3)
*cp++ = 0;
ip = (int *) cp;
while (ip < (int *) cend)
*ip++ = 0;
cp = (char *) ip;
while (cp < cend)
*cp++ = 0;
}
return (block);
#endif
}
#ifdef AMIGA
bisonfree(loc)
char *loc;
{
register unsigned long l1, l2;
register char *p;
if (loc == (char *)0)
return;
l1 = (unsigned long)loc;
l2 = l1 - 4;
if (l2 > l1)
return; /* check for wrap */
p = (char *)l2;
if (p[0] != 'A' || p[1] != 'M' || p[2] != 'E' || p[3] != 'M')
return; /* Not allocated memory */
free(p); /* Free the real location */
}
#endif
SHAR_EOF
cat << \SHAR_EOF > calc.y
%{
#include <ctype.h>
int regs[26];
int base;
int val;
int printflag;
%}
%start stmt
%token DIGIT LETTER EXIT
%left '|'
%left '&'
%left '+' '-'
%left '*' '/' '%'
%left UMINUS
%%
stmt : expr
{ val = $1; printflag = 1; }
| LETTER '=' expr
{ regs[$1] = $3; }
| EXIT
{ exit(0); }
;
expr : '(' expr ')'
{ $$ = $2; }
| expr '+' expr
{ if ($1 == 69)
{
$$ = 2;
printf ("$1 became %d\n", $1);
$1 = 69;
}
$$ = $1 + $3; }
| expr '-' expr
{ $$ = $1 - $3; }
| expr '*' expr
{ $$ = $1 * $3; }
| expr '/' expr
{ $$ = $1 / $3; }
| expr '%' expr
{ $$ = $1 % $3; }
| expr '|' expr
{ $$ = $1 | $3; }
| expr '&' expr
{ $$ = $1 & $3; }
| '-' expr %prec UMINUS
{ $$ = - $2; }
| LETTER
{ $$ = regs[$1]; }
| number
/* | '?'
{ yydebug = !yydebug; }
*/ ;
number : DIGIT
{ $$ = $1; base = ($1 == 0) ? 8 : 10; }
| number DIGIT
{ $$ = base * $1 + $2; }
;
%%
static int eol;
int
yylex()
{
int c;
while ( (c=getchar()) == ' ') {}
if (c == '\n')
{ eol = 1;
return 0; }
if (c == 'Q')
return(EXIT);
if (islower(c))
{
yylval = c - 'a';
return (LETTER);
}
if (isdigit(c))
{
yylval = c - '0';
return (DIGIT);
}
return (c);
}
yyerror(s)
char *s;
{
printf("%s\n", s);
}
main()
{
for (;;)
{
eol = 0;
printflag = 0;
if (yyparse()) printflag = 0;
if (printflag) printf("%d\n", val);
while (!eol) yylex();
}
}SHAR_EOF
# End of shell archive
exit 0